<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="档案编号">
              <j-input placeholder="请输入档案编号" v-model="queryParam.finalNo"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目名称">
              <j-input placeholder="请输入项目名称" v-model="queryParam.projectName"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="经营团队" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <select-team-input placeholder="请选择经营团队" v-model="queryParam.teamName" :tdlx="1" :teamType="0"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="承接人">
              <select-user-by-dep placeholder="请选择项目承接人" :multi="false" v-model="queryParam.undertaker" />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="签订单位" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <select-Company-input placeholder="请选择签订单位" v-model="queryParam.signUnit"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="业主单位" prop="ownerUnit" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <select-customer-input
                commercialType="1"
                v-model="queryParam.ownerUnit"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="业绩归属年度">
              <j-dict-select-tag type="list" v-model="queryParam.year" dictCode="yjgsnd" placeholder="请选择归属年度"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目来源" prop="ownerUnit">
              <j-dict-select-tag
                type="list"
                v-model="queryParam.projectSource"
                dictCode="xmly_type"
                placeholder="请选择项目来源"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="项目变更状态">
              <j-dict-select-tag
                type="list"
                v-model="queryParam.changeStatus"
                dictCode="change_status"
                placeholder="请选择项目变更状态"
              />
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
          <a-form-item label="项目档案状态" :labelCol="labelCol">
            <j-dict-select-tag placeholder="请选择项目档案状态" v-model="queryParam.currentProjectStatus" dictCode="current_project_status"/>
          </a-form-item>
        </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="合同档案状态">
              <j-dict-select-tag
                type="list"
                v-model="queryParam.collectionContractStatus"
                dictCode="project_contract_final_status"
                placeholder="请选择合同档案状态"
              />
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="业务分类" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <business-category-name-select v-model="queryParam.businessCategoryName" @back="businessCategoryHandle"/>
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="数据来源" >
              <j-dict-select-tag
                type="list"
                v-model="queryParam.isPrepareEstablish"
                dictCode="omc_project_type"
                placeholder="请选择数据来源"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="流程状态">
              <j-dict-select-tag placeholder="请选择流程状态" v-model="queryParam.status" dictCode="project_process_tatus"/>
            </a-form-item>
          </a-col>
          <!-- <template v-if="toggleSearchStatus"></template> -->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a> -->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button
        :loading="exportLoading"
        type="primary"
        icon="download"
        @click="handleExportXls('项目档案')"
        :disabled="isDisabledAuth('erpOmcProject:export')">导出
      </a-button>
      <!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
              <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpOmcProject:import')">导入</a-button>
            </a-upload>-->
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <!--      <a-dropdown v-if="selectedRowKeys.length > 0">
              <a-menu slot="overlay">
                <a-menu-item key="1" @click="batchDel" :disabled="isDisabledAuth('erpOmcProject:delete')"><a-icon type="delete"/>删除</a-menu-item>
              </a-menu>
              <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
            </a-dropdown>-->
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item, index) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12" :key="index">
                    <a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox>
                  </a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right; margin-top: -20px;">
          <a-icon type="setting" :style="iconStyle"/>
        </a>
      </a-popover>
    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
          style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:scrollX}"
        bordered
        :components="draggableComponent"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <template slot="status" slot-scope="status">
          <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="pcaSlot" slot-scope="text">
          <div>{{ getPcaText(text) }}</div>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <!--
                <span slot="action" slot-scope="text, record">
                    <a-button
                        class="ruleButton"
                        :ghost="true"
                        type="primary"
                        icon="edit"
                        @click="handleEdit(record)"
                        :disabled="isDisabledAuth('erpOmcProject:edit')"
                />
                <a-divider type="vertical"/>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                    <a-button
                            class="ruleButton"
                            :ghost="true"
                            type="primary"
                            icon="delete"
                            :disabled="isDisabledAuth('erpOmcProject:delete')"/>
                </a-popconfirm>
                </span>
        -->
      </a-table>
    </div>
    <erp-omc-project-modal ref="modalForm" @ok="modalFormOk"></erp-omc-project-modal>
  </a-card>
</template>
<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpOmcProjectModal from './modules/ErpOmcProjectModal'
import Area from '@/components/_util/Area'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'
import SelectTeamInput from '@views/scy/components/SelectTeamInput'
import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
import SelectCustomerInput from '@views/scy/components/SelectCustomerInput'
import BusinessCategoryNameSelect from '@views/erp/components/BusinessCategoryNameSelect'
import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
export default {
  name: 'ErpOmcProjectList',
  mixins: [JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
  components: {
    ErpOmcProjectModal,
    SelectTeamInput,
    SelectUserByDep,
    SelectCustomerInput,
    BusinessCategoryNameSelect,
    SelectCompanyInput
  },
  data() {
    return {
      /* 排序参数 */
      isorter: {
        column: '',
        order: ''
      },
      description: '立项档案信息管理页面',
      // 表头
      columns: [],
      // 列设置
      settingColumns: [],
      // 列定义
      defColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          ellipsis: true,
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '档案编号',
          align: 'center',
          dataIndex: 'finalNo',
          ellipsis: true,
          width: 135
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'projectName',
          ellipsis: true,
          width: 135
        },
        {
          title: '经营团队',
          align: 'center',
          dataIndex: 'teamName_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '项目承接人',
          align: 'center',
          dataIndex: 'undertaker_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '签订单位',
          align: 'center',
          dataIndex: 'signUnit_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '项目归属年度',
          align: 'center',
          dataIndex: 'year_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '业主单位',
          align: 'center',
          dataIndex: 'ownerUnit_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '项目来源',
          align: 'center',
          dataIndex: 'projectSource_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '数据来源',
          align: 'center',
          dataIndex: 'isPrepareEstablish_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '预计合同额(元)',
          align: 'center',
          dataIndex: 'estimatedContractAmount',
          ellipsis: true,
          width: 135
        },
        {
          title: '经营绩效(元)',
          align: 'center',
          dataIndex: 'businessPerformance',
          ellipsis: true,
          width: 120
        },
        // {
        //   title: '立项日期',
        //   align: 'center',
        //   dataIndex: 'projectEstablishDate',
        //   customRender: function (text) {
        //     return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
        //   }
        // },
        // {
        //   title: '经办部门',
        //   align: 'center',
        //   dataIndex: 'handlerDeptId_dictText',
        // },
        // {
        //   title: '是否招投标',
        //   align: 'center',
        //   dataIndex: 'isBidding_dictText',
        // },
        // {
        //   title: '联系人',
        //   align: 'center',
        //   dataIndex: 'contacts_dictText',
        // },
        // {
        //   title: '联系方式',
        //   align: 'center',
        //   dataIndex: 'contactTel',
        // },
        {
          title: '项目变更状态',
          align: 'center',
          dataIndex: 'changeStatus_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '项目档案状态',
          align: 'center',
          dataIndex: 'currentProjectStatus_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '合同档案状态',
          align: 'center',
          dataIndex: 'collectionContractStatus_dictText',
          ellipsis: true,
          width: 135
        },
        {
          title: '流程状态',
          align: 'center',
          dataIndex: 'status_dictText',
          ellipsis: true,
          width: 135
        }
        // {
        //   title: '是否预立项',
        //   align: 'center',
        //   dataIndex: 'isPrepareEstablish_dictText',
        // },
        //
        // {
        //   title: '县区编码',
        //   align: 'center',
        //   dataIndex: 'areaCode',
        //   scopedSlots: { customRender: 'pcaSlot' },
        // },
        /*  {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action' }
          } */
      ],
      url: {
        list: '/api/erp/omc/project/erpOmcProject/queryProjectList',
        delete: '/api/erp/omc/project/erpOmcProject/delete',
        deleteBatch: '/api/erp/omc/project/erpOmcProject/deleteBatch',
        exportXlsUrl: '/api/erp/omc/project/erpOmcProject/exportFinal',
        importExcelUrl: 'api/erp/omc/project/erpOmcProject/importExcel'
      },
      dictOptions: {},
      pcaData: '',
      superFieldList: []
    }
  },
  created() {
    this.pcaData = new Area()
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    getPcaText(code) {
      return this.pcaData.getText(code);
    },
    initDictConfig() {
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'year', text: '归属年度', dictCode: 'yjgsnd' })
      fieldList.push({ type: 'string', value: 'accountAdmin', text: '台账管理员', dictCode: '' })
      fieldList.push({ type: 'string', value: 'projectAddress', text: '项目地址', dictCode: '' })
      fieldList.push({ type: 'Text', value: 'outline', text: '项目内容概要', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'prepareProjectId',
        text: '预立项',
        dictCode: 'erp_omc_prepare_project,mc,id'
      })
      fieldList.push({ type: 'string', value: 'projectName', text: '项目名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'projectNo', text: '项目编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'projectType', text: '项目类型', dictCode: 'xmlx_type' })
      fieldList.push({ type: 'string', value: 'ownerUnit', text: '业主单位', dictCode: '' })
      fieldList.push({ type: 'string', value: 'handler', text: '经办人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'handingDepartmernt', text: '经办部门', dictCode: 'departments' })
      fieldList.push({ type: 'string', value: 'teamName', text: '经营团队', dictCode: 'teams' })
      fieldList.push({ type: 'string', value: 'undertaker', text: '承接人', dictCode: '' })
      fieldList.push({ type: 'date', value: 'projectEstablishDate', text: '立项日期' })
      fieldList.push({ type: 'string', value: 'signUnit', text: '签订单位', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'estimatedContractAmount', text: '预计合同额(元)', dictCode: '' })
      fieldList.push({ type: 'string', value: 'estimatedContractcapitalChineseAmount', text: '预计合同额(元)大写', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'isEnvironmentalAssessmentProject',
        text: '是否环评项目',
        dictCode: 'YES_OR_NO'
      })
      fieldList.push({ type: 'string', value: 'contacts', text: '联系人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'contactTel', text: '联系方式', dictCode: '' })
      fieldList.push({ type: 'string', value: 'projectSource', text: '项目来源', dictCode: 'xmly_type' })
      fieldList.push({ type: 'string', value: 'isPrepareEstablish', text: '数据来源', dictCode: 'omc_project_type' })
      fieldList.push({ type: 'string', value: 'status', text: '流程状态', dictCode: 'project_status' })
      fieldList.push({ type: 'string', value: 'attachment', text: '相关附件', dictCode: '' })
      fieldList.push({ type: 'string', value: 'isPrepareEstablish', text: '是否预立项', dictCode: 'YES_OR_NO' })
      fieldList.push({ type: 'string', value: 'isBidding', text: '是否招投标', dictCode: 'YES_OR_NO' })
      fieldList.push({ type: 'Text', value: 'establishReason', text: '立项事由及说明', dictCode: '' })
      fieldList.push({ type: 'pca', value: 'areaCode', text: '县区编码' })
      this.superFieldList = fieldList
    },
    businessCategoryHandle(obj) {
      if (obj) {
        this.queryParam.businessCategory = obj.categoryCode;
      }
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
